<?xml version="1.0" encoding="utf-8"?>
<!--
                                                                                     
 h       t     t                ::       /     /                     t             / 
 h       t     t                ::      //    //                     t            // 
 h     ttttt ttttt ppppp sssss         //    //  y   y       sssss ttttt         //  
 hhhh    t     t   p   p s            //    //   y   y       s       t          //   
 h  hh   t     t   ppppp sssss       //    //    yyyyy       sssss   t         //    
 h   h   t     t   p         s  ::   /     /         y  ..       s   t    ..   /     
 h   h   t     t   p     sssss  ::   /     /     yyyyy  ..   sssss   t    ..   /     
                                                                                     
	<https://y.st./>
	Copyright © 2016 Alex Yst <mailto:copyright@y.st>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <https://www.gnu.org./licenses/>.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="https://y.st./en/weblog/2016/10-October/07.xhtml" />
		<title>Misusing closures &lt;https://y.st./en/weblog/2016/10-October/07.xhtml&gt;</title>
		<link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
		<link rel="stylesheet" type="text/css" href="/link/basic.css" />
		<link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
		<script type="text/javascript" src="/script/javascript.js" />
		<meta name="viewport" content="width=device-width" />
	</head>
	<body>
		<nav>
			<p>
				<a href="/en/">Home</a> |
				<a href="/en/a/about.xhtml">About</a> |
				<a href="/en/a/contact.xhtml">Contact</a> |
				<a href="/a/canary.txt">Canary</a> |
				<a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
				<a href="/en/opinion/">Opinions</a> |
				<a href="/en/coursework/">Coursework</a> |
				<a href="/en/law/">Law</a> |
				<a href="/en/a/links.xhtml">Links</a> |
				<a href="/en/weblog/2016/10-October/07.xhtml.asc">{this page}.asc</a>
			</p>
			<hr/>
			<p>
				Weblog index:
				<a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
				<a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
				<a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
			</p>
			<hr/>
			<p>
				Jump to entry:
				<a href="/en/weblog/2015/03-March/07.xhtml">&lt;&lt;First</a>
				<a rel="prev" href="/en/weblog/2016/10-October/06.xhtml">&lt;Previous</a>
				<a rel="next" href="/en/weblog/2016/10-October/08.xhtml">Next&gt;</a>
				<a href="/en/weblog/latest.xhtml">Latest&gt;&gt;</a>
			</p>
			<hr/>
		</nav>
		<header>
			<h1>Misusing closures</h1>
			<p>Day 00580: Friday, 2016 October 07</p>
		</header>
<p>
	Current countdowns:
</p>
<ul>
	<li>4 unfinished weblog entries in <a href="/en/weblog/2016/07-July/">July</a></li>
	<li>10 days until my old domain registrar can no longer counter my charge dispute</li>
</ul>
<p>
	In <span title="Globalization">POLS 1503</span> this week, one of my assignments is to write an essay on either the Canadian magazine dispute or Norway and Japan&apos;s efforts to get country-specific exceptions to the global ban on whaling.
	So which did I choose? Both! My plan was to write up the initial drafts of these essays yesterday, but I really wasn&apos;t feeling well.
	At least O got some of my other homework done though.
	Today, I wrote up the drafts.
	Aside from the replies that I need to leave later in the week to other students&apos; discussion posts and a bit of cleanup work on the essays, I&apos;m finished with <span title="Globalization">POLS 1503</span> for the week.
</p>
<p>
	One of the assigned webpages for reading in <span title="Online Education Strategies">UNIV 1001</span> this week is behind a login wall and another maliciously blocks <abbr title="The Onion Router">Tor</abbr> users, so there&apos;s no point in linking to those two.
	Aside from them, these are the text and videos that we were to read and watch:
</p>
<ul>
<li><a href="https://www.youtube.com./watch?v=3rFNnhYMlQY">Study Skills &amp; Effective Note taking for Online Students - YouTube</a></li>
<li><a href="https://www.youtube.com./watch?v=AffuwyJZTQQ">How to Take Notes in Class: The 5 Best Methods - College Info Geek - YouTube</a></li>
<li><a href="http://onlinecollegecourses.com./2011/11/23/note-taking-strategies-for-online-students/">Note-Taking Strategies for Online Students - OnlineCollegeCourses.com</a></li>
<li><a href="http://www.studygs.net/shared/reading.htm">Attention Required! | CloudFlare</a></li>
<li><a href="http://www.studygs.net/shared/testing.htm">Attention Required! | CloudFlare</a></li>
</ul>
<p>
	Obviously, I couldn&apos;t read the page that was blocking me, but I read the rest and watched the two videos, then took an ungraded quiz and a graded quiz based on the subject matter of note-taking.
	If I&apos;d been as focused as I should have been yesterday, I&apos;d be done with my schoolwork today aside from my replies to the discussion posts of other students.
	I&apos;ve taken a large bite out of my final assignment this week, and I&apos;ll finish it up tomorrow.
	After that, I can compose as many of my discussion replies as possible (I may have to wait for more students to post before submitting all of my replies), go over my essays again, and get back to work on cleaning up this website&apos;s source code and filling in the blank spot in my journal.
	Tomorrow&apos;s assignment is a strange one, and I&apos;m required to read an article, take notes on it, then submit the notes for grading along with some other writing.
</p>
<p>
	I started fixing a small component of this website today, not realizing at the time what a huge project that that component would turn out to be.
	I&apos;ve automated the process of adding the subtitles to my journal entries.
	However, that came along with the painful process of removing all of the subtitles from the source code files of every journal entry that&apos;s already been written.
	Of course, this all had to be done by hand.
	The next component that I plan to work on will be the automation of the decision of which navigation elements to include on each page.
	This will be even more painful than today&apos;s project, as the navigation hints present in the source code will need to be removed from <strong>*every*</strong> page of the website.
	I&apos;ve also written my first-ever closure into the code.
	Normally, I don&apos;t use closures because I think that they&apos;re a cop-out.
	A closure is a function that you don&apos;t plan on reusing.
	If you&apos;ve written your code well, your functions should be general enough to use in other projects.
	However, I&apos;m not sure how to generalize the code this time.
	Aside from using a closure, my options are to use a lambda function, which is just as much of a cop-out as a closure but also less efficient, or to write the code as a file to be included every time that the loop runs, which probably means that the file has to be recompiled during each loop.
</p>
<p>
	...
	oh, drats.
	I just realized while writing this entry that my new closure is only called from within a single loop.
	Tomorrow, I should clean up the code of the closure and just insert it directly into the loop.
	Like I said, if you&apos;re using closures, you&apos;re probably writing your code incorrectly.
	If I had needed to call this closure from multiple locations in the code though, generalization would be the proper way to do this.
	The fact that this function is used only in one place does explain why I couldn&apos;t generalize it though; it&apos;s very specific to that one instance.
	It also explains why I had to use so many global variables from within the closure.
</p>
		<hr/>
		<p>
			Copyright © 2016 Alex Yst;
			You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
			If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
			My address is in the source comments near the top of this document.
			This license also applies to embedded content such as images.
			For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
		</p>
		<p>
			<abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
			This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F10-October%2F07.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F10-October%2F07.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
		</p>
	</body>
</html>

